package com.sunshine.lnuplus.ui.activity

import android.content.Intent
import android.os.Bundle
import com.sunshine.lnuplus.R
import com.sunshine.lnuplus.base.BaseActivity
import com.sunshine.lnuplus.callback.TimetableSettingCallBack
import com.sunshine.lnuplus.utils.StatusBarUtils
import com.sunshine.lnuplus.utils.TagHelper
import com.sunshine.lnuplus.view.AppSettingView

class AppSettingActivity : BaseActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_app_setting)

        StatusBarUtils.setStatusBarWithColor(this, color)
        title = "软件设置"
        val appSettingView = AppSettingView()
        appSettingView.setCallBack(object : TimetableSettingCallBack{
            override fun onChanged() {
                setResult(TagHelper.APPSETTING)
                finish()
                startActivity(Intent(this@AppSettingActivity, this@AppSettingActivity.javaClass))
            }
        })

        supportFragmentManager
            .beginTransaction()
            .replace(R.id.app_setting_view, appSettingView)
            .commit()
    }

    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if(requestCode == TagHelper.APPSETTING){
            when(resultCode){
                TagHelper.TIMETABLETHEME -> setResult(TagHelper.APPSETTING)
            }
        }
    }
}
